// ImagePackDlg.h : header file
//

#pragma once

#include <atlimage.h>
#include "ResourceFactory.h"
#include "tinyxml.h"
class ImageItem{
public:
	ImageItem(){
		name.Format(L"p%d",m_id++);
	}
	static void SectionBegin(){
		m_id = 1;
		sum_size = 0;
	}
	static void SectionEnd(){

	}
	void SetSize(int i){
		offset = sum_size ;//+ 1;
		size = i;
		sum_size += size;
		//sum_size += 1;
	}
	void SetData(BYTE *data){
		m_data  = data;
	}
	
	
public:
	static int m_id;//auto name 1....n
	CString name;
	int size;	//file size
	int offset;	//
	static int sum_size;
	BYTE *m_data;
};


class XmlFile
{
public:
	void CreateHeader();
};

// CImagePackDlg dialog
class CImagePackDlg : public CDialog
{
// Construction
public:
	CImagePackDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_IMAGEPACK_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedAdd();
	BOOL ScanDir(const CString &,CArray<ImageItem *>*);
	void InitImage(CImage*,PngItem*);
	void Parse(const CString &dir,
		const CStringA &,
		const CStringA &,
		TiXmlElement *category_element,
		CArray<ImageItem *> *png_list,
		CFile &);
	void Parse2(const CString &dir,
		TiXmlElement *png_element,
		CArray<ImageItem *> *png_list,
		CFile &save_file);
	BOOL XmlParse();
private:
	
public:
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedAdd2();
};
